﻿
namespace AgileZen.Models
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Runtime.Serialization;

    [DataContract]
    public class AgileZenModel : INotifyPropertyChanged
    {
        protected List<string> PropertiesChanged { get; set; }

        public event PropertyChangedEventHandler PropertyChanged;

        internal void Reset()
        {
            if (PropertiesChanged != null)
            {
                PropertiesChanged.Clear();
            }
        }

        protected void NotifyPropertyChanged(string info)
        {
            //create new list if the list is null
            PropertiesChanged = PropertiesChanged ?? new List<string>();

            //add this to track changed properties
            if (!PropertiesChanged.Contains(info))
            {
                PropertiesChanged.Add(info);
            }

            //fire delegates if something subscribed to it
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }
    }
}
